#ifndef __JPACKET_H__
#define __JPACKET_H__

#include <json/json.h>

struct Header {
	unsigned int    length;
};

class Jpacket
{
public:
    Jpacket();
    virtual ~Jpacket();
	static void(*encode)(std::string&);
    std::string& tostring();
    Json::Value& tojson();

    void end();
	int parse(std::string& str);
	Json::Value& operator[](const char* key)
	{
		return val[key];
	}

private:
    struct Header           header;

public:
    std::string             str;
    Json::Value             val;
    Json::Reader            reader;
    int                     len;
};

#endif
